<?php
function getlei($id){
	global $db;
	$u = $db->pe_select("category",array('jfscategory_id'=>$id),'jfscategory_name');
	return $u['jfscategory_name'];
}
switch ($act) {
	//#####################@ 产品添加 @#####################//
	case 'add':
		if (isset($_p_pesubmit)) {
			pe_token_match();
			if ($_FILES['jfsproduct_img']['size']) {
				pe_lead('include/class/upload.class.php');
				$upload = new upload($_FILES['jfsproduct_img']);
				$_p_info['jfsproduct_img'] = $upload->filehost;				
			}	
			$_p_info['jfsproduct_content'] = $_POST['content'];
			if ($db->pe_insert('phone',$_p_info,array('jfsproduct_content'))) {
				pe_success('产品添加成功!', 'admin.php?mod=jfsproduct');
			}
			else {
				pe_error('产品添加失败...');
			}
		}		
		$seo = pe_seo($menutitle='添加产品', '', '', 'admin');
		include(pe_tpl('product_add.html'));
	break;
	//#####################@ 产品修改 @#####################//
	case 'edit':
		$jfsproduct_id = intval($_g_id);
		if (isset($_p_pesubmit)) {
			pe_token_match();
			if ($_FILES['jfsproduct_img']['size']) {
				pe_lead('include/class/upload.class.php');
				$upload = new upload($_FILES['jfsproduct_img']);
				$_p_info['jfsproduct_img'] = $upload->filehost;				
			}
			$_p_info['jfsproduct_content'] = $_POST['content'];
			// pe_pr($_p_info);		
			if ($db->pe_update('phone', array('jfsproduct_id'=>$jfsproduct_id), $_p_info,array('jfsproduct_content'))) {
				pe_success('产品修改成功!', $_g_fromto);
			}
			else {
				pe_error('产品修改失败...');
			}
		}
		$info = $db->pe_select('phone', array('jfsproduct_id'=>$jfsproduct_id));		
		$seo = pe_seo($menutitle='修改产品', '', '', 'admin');
		include(pe_tpl('product_add.html'));
	break;
	//#####################@ 产品状态  @#####################//
	case 'state':
		pe_token_match();
		if ($db->pe_update('phone', array('jfsproduct_id'=>$_g_id),array("jfsproduct_state"=>$_g_state))) {
			pe_success('操作成功!');
		}
		else {
			pe_error('操作失败...');
		}
	break;	
	//#####################@ 产品删除 @#####################//
	case 'del':
		pe_token_match();
		if ($db->pe_delete('phone', array('jfsproduct_id'=>is_array($_p_jfsproduct_id) ? $_p_jfsproduct_id : $_g_id))) {
			pe_success('产品删除成功!');
		}
		else {
			pe_error('产品删除失败...');
		}
	break;
	//#####################@ 排序 @#####################//
	case 'order':
		pe_token_match();
		foreach ($_p_jfsproduct_order as $k=>$v) {
			$result = $db->pe_update('phone', array('jfsproduct_id'=>$k), array('jfsproduct_order'=>$v));
		}
		if ($result) {
			//cache_write('ad');
			pe_success('排序成功!');
		}
		else {
			pe_error('排序失败...');
		}
	break;
	//#####################@ 产品列表 @#####################//
	default:
		$_g_key && $sqlwhere .= " and `jfsproduct_name` like '%{$_g_key}%'";
		$sqlwhere .= " order by `jfsproduct_order` asc";
		$info_list = $db->pe_selectall('phone',$sqlwhere,'*', array(5, $_g_page));		
		$house_server = $db ->pe_selectall('category','','*');
		$seo = pe_seo($menutitle='产品', '', '', 'admin');
		include(pe_tpl('product_list.html'));
	break;
}
?>